<template>
	<view class="">
		<noData v-if="lists.length < 1" type="1" ndText="暂无订单"></noData>
		<view v-else class="order-box" v-for="(item,index) in lists" :key="index" @click="toUrl(item)">
			<view class="order-nor" v-show="orderType == 2">
				<view class="order-nor-left">订单编号：{{item.order_sn}}</view>
				<view class="order-nor-right">{{item.order_status_text}}</view>
			</view>
			<view class="order-item">
				<image class="order-img" :src="item.goods ? $IMG_URL+item.goods.image : $IMG_URL+item.image" mode="">
				</image>
				<view class="order-right">
					<view class="order-right-top">{{item.goods?item.goods.name:item.name}}</view>
					<view class="order-right-bottom">
						<view class="order-right-bottom-left">
							<text>{{isJifen == 1 ? '￥':'积分:'}}</text>{{ item.goods ?item.goods.price:item.price}}
						</view>
						<!-- <view class="order-right-bottom-right" v-show="orderType == 1  || orderType == 3">
							x1</view> -->
						<view class="order-right-bottom-right-sale" v-show="orderType == 5">{{orderStatus}}</view>
					</view>
				</view>
			</view>
			<view v-show="orderType == 2 || orderType == 3" class="diver"></view>
			<view class="order-time" v-show="orderType == 2">
				<view class="order-time-left">{{getTime(item.createtime)}}</view>
				<view class="order-time-right">
					<!-- 共1件商品 -->
					<text class="order-time-right-1">合计</text><text
						class="order-time-right-2">{{isJifen == 1 ? '￥':'积分:'}}</text>
					<text class="order-time-right-3">{{item.pay_price}}</text>
				</view>
			</view>
		<!-- 	<view class="order-all" v-show="orderType == 3">
				<view>商品总额</view>
				<view>￥456</view>
			</view> -->
			<view class="warehouse-btns" v-show="orderType == 4">
				<view class="warehouse-btns-right"
					@click.stop="navigator('/pages/message/sendHuo/sendHuo?confirmType='+2+'&confirmTitle='+'发货'+'&goods_id='+item.id)">
					发货</view>
				<view class="warehouse-btns-left" @click.stop="jiShow(item)">寄售</view>
			</view>
		</view>
	</view>

</template>

<script>
	import noData from '@/components/no-data.vue';
	export default {
		name: "order-list",
		components: {
			noData
		},
		props: {
			isJifen: {
				detailType: [Boolean, String],
				default: () => 1 //1 其他 2 积分
			},
			lists: {
				type: Array,
				default: () => []
			},
			orderStatus: {
				detailType: [Number, String],
				default: () => ''
			},
			orderType: {
				detailType: [Number, String],
				default: () => 1 //1不展示订单编号其他 2 展示订单编号以及时间 3商品总额 详情 4.我的仓库 5我的寄售
			},
			orderRob: {
				detailType: [Number, String],
				default: () => 1
			}
		},
		data() {
			return {

			};
		},
		methods: {
			// 寄售按钮
			jiShow(item) {
				this.$http('other.getsystem', {}, '抢购中...').then(res => {
					if (res.code == 1) {
						if (res.data.is_jieshou == 0) {
							uni.showToast({
								icon: 'none',
								title: '寄售暂未开启'
							})
						} else {
							this.navigator('/pages/me/consignment/consignment?goods_id=' + item.id)
						}
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},

			// 跳转详情
			toUrl(item) {
				if (this.orderType == 5) {
					uni.navigateTo({
						url: '/pages/index/shopDetail/shopDetail?detailType=' + 3 + '&id=' + item.id +
							'&isJifen=' + this.isJifen
					})
					return
				} else if (this.orderRob == 1) {
					this.navigator('/pages/me/orderRobDetail/orderRobDetail?order_sn=' + item.order_sn + '&isJifen=' + this
						.isJifen)
				} else if (this.orderType == 4) {
					// this.navigator('/pages/me/orderRobDetail/orderRobDetail?order_sn=' + item.id)
				} else {
					this.navigator('/pages/me/orderDetail/orderDetail?order_sn=' + item.order_sn + '&isJifen=' + this
						.isJifen)
				}
			},
			navigator(url) {
				uni.navigateTo({
					url: url
				})
			},
			getTime(timestamp) {
				let date = new Date(parseInt(timestamp) * 1000);
				let Year = date.getFullYear();
				let Moth = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
				let Day = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
				let Hour = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
				let Minute = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
				let Sechond = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
				return Year + '.' + Moth + '.' + Day + '   ' + Hour + ':' + Minute + ':' + Sechond;
			}
		}
	}
</script>

<style lang="scss">
	.order-box {
		background-color: #fff;
		padding: 20rpx;

		.order-nor {
			display: flex;
			justify-content: space-between;
			margin-bottom: 30rpx;

			.order-nor-left {
				font-weight: 400;
				font-size: 26rpx;
				color: #666666;
			}

			.order-nor-right {
				font-weight: 500;
				font-size: 28rpx;
				color: #6FAD19;
			}
		}

		.order-item {
			display: flex;

			.order-img {
				width: 200rpx;
				height: 200rpx;
				border-radius: 20rpx;
			}

			.order-right {
				width: 440rpx;
				margin-left: 20rpx;

				.order-right-top {
					font-size: 28rpx;
					color: #333333;
				}

				.order-right-bottom {
					display: flex;
					justify-content: space-between;
					margin-top: 60rpx;

					.order-right-bottom-left {
						font-weight: bold;
						font-size: 32rpx;
						color: #DD0403;

						text {
							font-size: 22rpx;
						}
					}

					.order-right-bottom-right {
						font-weight: 400;
						font-size: 24rpx;
						color: #999999;
					}

					.order-right-bottom-right-sale {
						font-weight: 500;
						font-size: 28rpx;
						color: #6FAD19;
					}
				}
			}
		}

		.diver {
			width: 654rpx;
			height: 1rpx;
			background: #EEEEEE;
			margin: 30rpx 0;
		}

		.order-all {
			display: flex;
			justify-content: space-between;
			font-weight: 500;
			font-size: 28rpx;
			color: #333333;
			margin-top: 20rpx;
		}

		.order-time {
			display: flex;
			justify-content: space-between;

			.order-time-left {
				font-weight: 500;
				font-size: 24rpx;
				color: #999999;
				margin-top: 10rpx;
			}

			.order-time-right {
				font-weight: 400;
				font-size: 20rpx;
				color: #666666;

				.order-time-right-1 {
					margin: 0 20rpx;
				}

				.order-time-right-2 {
					font-weight: bold;
					font-size: 22rpx;
					color: #333333;
				}

				.order-time-right-3 {
					font-weight: bold;
					font-size: 32rpx;
					color: #333333;
				}
			}
		}

		.warehouse-btns {
			display: flex;
			justify-content: flex-end;
			margin-top: 20rpx;

			.warehouse-btns-left {
				width: 144rpx;
				height: 56rpx;
				border-radius: 50rpx;
				font-weight: 400;
				font-size: 24rpx;
				color: #FFFFFF;
				line-height: 56rpx;
				text-align: center;
				margin-left: 20rpx;
				background: linear-gradient(90deg, #6AAE2B 0%, #1B7E38 100%);
			}

			.warehouse-btns-right {
				width: 144rpx;
				height: 56rpx;
				color: #333333;
				background: #F6F6F6;
				border-radius: 50rpx;
				font-weight: 400;
				font-size: 24rpx;
				line-height: 56rpx;
				text-align: center;
			}
		}
	}
</style>